<?php
class AnalysisApp extends CommonApp {
 
   	//工资分析
    public function salaryAct(){
        $menu = self::menu('salary');
        $result = $this->common($menu['act']);

        $this->assign('menu',$menu);
        $this->assign('result',$result);
        $this->assign('major',M('category')->item2submenu('class',array('level'=>'1')));
        $this->assign('year',M('category')->item2submenu('year',array('level'=>'1')));
        $this->display('Analysis/index');
    }

  	//公司分析
    public function companyAct(){
        $menu = self::menu('company');
        $result = $this->common($menu['act']);
        $this->assign('menu',$menu);
        $this->assign('result',$result);
        $this->assign('major',M('category')->item2submenu('class',array('level'=>'1')));
        $this->assign('year',M('category')->item2submenu('year',array('level'=>'1')));
        $this->display('Analysis/index');
    }

    //就业创业分析
    public function employmentAct(){
        $menu = self::menu('employment');
        $result = $this->common($menu['act']);
    	$this->assign('menu',$menu);
        $this->assign('result',$result);
        $this->assign('major',M('category')->item2submenu('class',array('level'=>'1')));
        $this->assign('year',M('category')->item2submenu('year',array('level'=>'1')));
        $this->display('Analysis/index');
    }

    //专业相关度分析
    public function relatedAct(){
    	$menu = self::menu('related');
        $result = $this->common($menu['act']);
        $this->assign('menu',$menu);
        $this->assign('result',$result);
        $this->assign('major',M('category')->item2submenu('class',array('level'=>'1')));
        $this->assign('year',M('category')->item2submenu('year',array('level'=>'1')));
        $this->display('Analysis/index');
    }

    //共同函数
    public function common($analysis_type){
        $company_type = C('company_type');//公司融资情况
        $related = C('related');//专业相关度
        $type = C('type');//工作类型
        $result = $table = $ids = $option = $option2 = $option3 = '';
        $search = array();
        $search['where'] = "1 ";

        //搜索毕业年份
        if(My::arr2var($_GET,'year')!=''){
            $year = I('get.year');
            $search['where'] .= "AND `year` = '{$year}' ";
        }
        //搜索专业
        if(My::arr2var($_GET,'major')!=''){
            $major = $_GET['major'];
            $search['where'] .= "AND `major` = '{$major}' ";
        }

        //根据search，找出select选中的条件
        $id = DB('members')->where($search['where'])->field('id')->select();
        if($id)
            foreach ($id as &$value)
                $ids .=  ','.$value['id'];
        else 
            return false;
        $ids = substr($ids,'1');
        //毕业年份
        $gra_year = DB('info')->where("`parent_id` in (".$ids.")")->field('gra_year')->group('gra_year')->select();
        //采集年份
        $year = DB('info')->where("`parent_id` in (".$ids.")")->field('year')->group('year')->select();
        //公司融资情况 
        $company_types = DB('info')->where("`parent_id` in (".$ids.")")->field('company_type as name')->group('company_type')->select();
        //工作类型
        $types = DB('info')->where("`parent_id` in (".$ids.")")->field('type as name')->group('type')->select();
        //工作相关度
        $relateds = DB('info')->where("`parent_id` in (".$ids.")")->field('related as name')->group('related')->select();
        //工资
        $salary = DB('info')->where("`parent_id` in (".$ids.")")->field('price')->group('price')->select();
        //采集年份数组
        $years = $company_types1 = array();
        foreach($year as $k => $v)
            $years[] = $v['year'];
        //分析类型
        if($analysis_type == 'salary'){

            //毕业后几年的数组
            foreach ($gra_year as $key => $value) {
                $ring[$value['gra_year']]['0']['value'] = $table[$value['gra_year']]['price_3'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND price <= 3000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['1']['value'] = $table[$value['gra_year']]['3_price_4'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 3000 < price AND price <= 4000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['2']['value'] = $table[$value['gra_year']]['4_price_5'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 4000 < price AND price <= 5000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['3']['value'] = $table[$value['gra_year']]['5_price_6'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 5000 < price AND price <= 6000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['4']['value'] = $table[$value['gra_year']]['6_price_7'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 6000 < price AND price <= 7000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['5']['value'] = $table[$value['gra_year']]['7_price_8'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 7000 < price AND price <= 8000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['6']['value'] = $table[$value['gra_year']]['8_price_9'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 8000 < price AND price <= 9000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['7']['value'] = $table[$value['gra_year']]['9_price_10'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 9000 < price AND price <= 10000 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['8']['value'] = $table[$value['gra_year']]['10_price'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND 10000 < price AND `parent_id` in (".$ids.")")->count();
                $table[$value['gra_year']]['avg_price'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND `parent_id` in (".$ids.")")->avg('price');
                $table[$value['gra_year']]['max_price'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND `parent_id` in (".$ids.")")->max('price');
            }
            $price_a = array('小于3K','3K-4K','4K-5K','5K-6K','6K-7K','7K-8K','8K-9K','9K-10K','10K以上');
            foreach ($ring as $key => &$value){
                foreach ($value as $key1 => &$value1) {
                     $value1['name'] = $price_a[$key1];
                }
            }
            foreach ($table as $key2 => $value2) {
                unset($value2['avg_price']);
                unset($value2['max_price']);
                $value2 = array_values($value2);
                $option[$key2]['xAxis']['type'] = 'category';
                $option[$key2]['xAxis']['data'] = $option2[$key2]['legend']['data'] = $price_a;
                $option[$key2]['yAxis']['type'] = 'value';
                $option[$key2]['series']['data'] = $value2;
                $option[$key2]['series']['type'] = 'bar';
                $option2[$key2]['tooltip']['trigger'] = 'item';
                $option2[$key2]['tooltip']['formatter'] = "{b}:{c}人({d}%)";
                $option2[$key2]['legend']['orient'] = 'vertical';
                $option2[$key2]['legend']['x'] = 'left';
                $option2[$key2]['series']['name'] = '访问来源';
                $option2[$key2]['series']['type'] = 'pie';
                $option2[$key2]['series']['radius'] = array('50%','70%');
                $option2[$key2]['series']['avoidLabelOverlap'] = false;
                $option2[$key2]['series']['label']['normal']['show'] = false;
                $option2[$key2]['series']['label']['normal']['position'] = 'center';
                $option2[$key2]['series']['label']['emphasis']['show'] = true;
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontSize'] = '30';
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontWeight'] = 'bold';
                $option2[$key2]['series']['labelLine']['normal']['show'] = false;
                $option2[$key2]['series']['data'] = $ring[$key2];
            }
            foreach($salary as $k => $v){
                if($v['price'] <= '3000')
                    $salarys['0']['name'] = '小于3K';
                elseif('3000' < $v['price'] AND $v['price'] <= '4000')
                    $salarys['1']['name'] = '3K-4K';
                elseif('4000' < $v['price'] AND $v['price'] <= '5000')
                    $salarys['2']['name'] = '4K-5K';
                elseif('5000' < $v['price'] AND $v['price'] <= '6000')
                    $salarys['3']['name'] = '5K-6K';
                elseif('6000' < $v['price'] AND $v['price'] <= '7000')
                    $salarys['4']['name'] = '6K-7K';
                elseif('7000' < $v['price'] AND $v['price'] <= '8000')
                    $salarys['5']['name'] = '7K-8K';
                elseif('8000' < $v['price'] AND $v['price'] <= '9000')
                    $salarys['6']['name'] = '8K-9K';
                elseif('9000' < $v['price'] AND $v['price'] <= '10000')
                    $salarys['7']['name'] = '9K-10K';
                elseif('10000' < $v['price'])
                    $salarys['8']['name'] = '10K以上';
            }
            //近几年工资走向图
            foreach($salarys as $key_type => &$value_type){
                $value_type['type'] = 'line';
                foreach($year as $key_type1 => $value_type1){
                    if($key_type == '0')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND price <= 3000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '1')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 3000 < price AND price <= 4000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '2')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 4000 < price AND price <= 5000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '3')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 5000 < price AND price <= 6000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '4')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 6000 < price AND price <= 7000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '5')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 7000 < price AND price <= 8000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '6')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 8000 < price AND price <= 9000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '7')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 9000 < price AND price <= 10000 AND `parent_id` in (".$ids.")")->count();
                    elseif($key_type == '8')
                        $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND 10000 < price AND `parent_id` in (".$ids.")")->count();
                }
                // $value_type['name'] = $company_type[$value_type['name']];
            }
            //平均工资
            foreach ($years as $key => $value) {
                $data[] = DB('info')->where("year = '".$value."' AND `parent_id` in (".$ids.")")->avg('price');
            } 
            //平均工资
            foreach ($years as $key => $value) {
                $data1[] = DB('info')->where("year = '".$value."' AND `parent_id` in (".$ids.")")->max('price');
            }
            $option3['0']['title']['text'] = '毕业跟踪趋势走向图';
            $option3['0']['tooltip']['trigger'] = 'axis';
            $option3['0']['legend']['data'] = $price_a;
            $option3['0']['grid']['left'] = '3%';
            $option3['0']['grid']['right'] = '3%';
            $option3['0']['grid']['bottom'] = '3%';
            $option3['0']['grid']['containLabel'] = true;
            $option3['0']['toolbox']['feature']['saveAsImage'] = '';
            $option3['0']['xAxis']['type'] = $option4['0']['xAxis']['type'] = $option5['0']['xAxis']['type'] = 'category';
            $option3['0']['xAxis']['boundaryGap'] = false;
            $option3['0']['xAxis']['data'] = $option4['0']['xAxis']['data'] = $option5['0']['xAxis']['data'] = $years;
            $option3['0']['yAxis']['type'] = $option4['0']['yAxis']['type'] = $option5['0']['yAxis']['type'] = 'value';
            $option3['0']['series'] = array_values($salarys);
            $option4['0']['series']['type'] = $option5['0']['series']['type'] = 'line';
            $option4['0']['series']['data'] = $data;
            $option5['0']['series']['data'] = $data1;
        }elseif($analysis_type == 'company'){
             //毕业后几年的工资融资情况
            foreach ($gra_year as $key => $value) {
                $ring[$value['gra_year']]['0']['value'] = $table[$value['gra_year']]['0'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 0 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['1']['value'] = $table[$value['gra_year']]['1'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 1 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['2']['value'] = $table[$value['gra_year']]['2'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 2 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['3']['value'] = $table[$value['gra_year']]['3'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 3 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['4']['value'] = $table[$value['gra_year']]['4'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 4 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['5']['value'] = $table[$value['gra_year']]['5'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 5 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['6']['value'] = $table[$value['gra_year']]['6'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 6 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['7']['value'] = $table[$value['gra_year']]['7'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND company_type = 7 AND `parent_id` in (".$ids.")")->count();
            }
            foreach ($ring as $key => &$value){
                foreach ($value as $key1 => &$value1) {
                     $value1['name'] = $company_type[$key1];
                }
            }
            //组装成图表格式
            foreach ($table as $key2 => $value2) {
                $value2 = array_values($value2);
                $option[$key2]['xAxis']['type'] = 'category';
                $option[$key2]['xAxis']['data'] = $option2[$key2]['legend']['data'] = $company_type;
                $option[$key2]['yAxis']['type'] = 'value';
                $option[$key2]['series']['data'] = $value2;
                $option[$key2]['series']['type'] = 'bar';
                $option2[$key2]['tooltip']['trigger'] = 'item';
                $option2[$key2]['tooltip']['formatter'] = "{b}:{c}人({d}%)";
                $option2[$key2]['legend']['orient'] = 'vertical';
                $option2[$key2]['legend']['x'] = 'left';
                $option2[$key2]['series']['name'] = '访问来源';
                $option2[$key2]['series']['type'] = 'pie';
                $option2[$key2]['series']['radius'] = array('50%','70%');
                $option2[$key2]['series']['avoidLabelOverlap'] = false;
                $option2[$key2]['series']['label']['normal']['show'] = false;
                $option2[$key2]['series']['label']['normal']['position'] = 'center';
                $option2[$key2]['series']['label']['emphasis']['show'] = true;
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontSize'] = '30';
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontWeight'] = 'bold';
                $option2[$key2]['series']['labelLine']['normal']['show'] = false;
                $option2[$key2]['series']['data'] = $ring[$key2];
            }

            $years = $company_types1 = array();
            foreach($company_types as $k => $v)
                    $company_types1[] = $company_type[$v['name']];
            //近几年公司融资情况
            foreach($company_types as $key_type => &$value_type){
                $value_type['type'] = 'line';
                foreach($year as $key_type1 => $value_type1){
                    $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND company_type = '".$value_type['name']."' AND `parent_id` in (".$ids.")")->count();
                }
                $value_type['name'] = $company_type[$value_type['name']];
            }
            $option3['0']['title']['text'] = '毕业跟踪趋势走向图';
            $option3['0']['tooltip']['trigger'] = 'axis';
            $option3['0']['legend']['data'] = $company_types1;
            $option3['0']['grid']['left'] = '3%';
            $option3['0']['grid']['right'] = '3%';
            $option3['0']['grid']['bottom'] = '3%';
            $option3['0']['grid']['containLabel'] = true;
            $option3['0']['toolbox']['feature']['saveAsImage'] = '';
            $option3['0']['xAxis']['type'] = 'category';
            $option3['0']['xAxis']['boundaryGap'] = false;
            $option3['0']['xAxis']['data'] = $years;
            $option3['0']['yAxis']['type'] = 'value';
            $option3['0']['series'] = $company_types;
        }elseif($analysis_type == 'employment'){
            //毕业后几年的数组
            foreach ($gra_year as $key => $value) {
                $ring[$value['gra_year']]['0']['value'] = $table[$value['gra_year']]['doing'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND type = 0 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['1']['value'] = $table[$value['gra_year']]['job'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND type = 1 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['2']['value'] = $table[$value['gra_year']]['school'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND type = 2 AND `parent_id` in (".$ids.")")->count();
            }
            foreach ($ring as $key => &$value){
                foreach ($value as $key1 => &$value1) {
                     $value1['name'] = $type[$key1];
                }
            }
            //组装成图表格式
            foreach ($table as $key2 => $value2) {
                $value2 = array_values($value2);
                $option[$key2]['xAxis']['type'] = 'category';
                $option[$key2]['xAxis']['data'] = $option2[$key2]['legend']['data'] = $type;
                $option[$key2]['yAxis']['type'] = 'value';
                $option[$key2]['series']['data'] = $value2;
                $option[$key2]['series']['type'] = 'bar';
                $option2[$key2]['tooltip']['trigger'] = 'item';
                $option2[$key2]['tooltip']['formatter'] = "{b}:{c}人({d}%)";
                $option2[$key2]['legend']['orient'] = 'vertical';
                $option2[$key2]['legend']['x'] = 'left';
                $option2[$key2]['series']['name'] = '访问来源';
                $option2[$key2]['series']['type'] = 'pie';
                $option2[$key2]['series']['radius'] = array('50%','70%');
                $option2[$key2]['series']['avoidLabelOverlap'] = false;
                $option2[$key2]['series']['label']['normal']['show'] = false;
                $option2[$key2]['series']['label']['normal']['position'] = 'center';
                $option2[$key2]['series']['label']['emphasis']['show'] = true;
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontSize'] = '30';
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontWeight'] = 'bold';
                $option2[$key2]['series']['labelLine']['normal']['show'] = false;
                $option2[$key2]['series']['data'] = $ring[$key2];
            }
            foreach($types as $k => $v)
                    $types1[] = $type[$v['name']];
            //近几年公司融资情况
            foreach($types as $key_type => &$value_type){
                $value_type['type'] = 'line';
                foreach($year as $key_type1 => $value_type1){
                    $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND type = '".$value_type['name']."' AND `parent_id` in (".$ids.")")->count();
                }
                $value_type['name'] = $type[$value_type['name']];
            }
            $option3['0']['title']['text'] = '毕业跟踪趋势走向图';
            $option3['0']['tooltip']['trigger'] = 'axis';
            $option3['0']['legend']['data'] = $types1;
            $option3['0']['grid']['left'] = '3%';
            $option3['0']['grid']['right'] = '3%';
            $option3['0']['grid']['bottom'] = '3%';
            $option3['0']['grid']['containLabel'] = true;
            $option3['0']['toolbox']['feature']['saveAsImage'] = '';
            $option3['0']['xAxis']['type'] = 'category';
            $option3['0']['xAxis']['boundaryGap'] = false;
            $option3['0']['xAxis']['data'] = $years;
            $option3['0']['yAxis']['type'] = 'value';
            $option3['0']['series'] = $types;
        }elseif($analysis_type == 'related'){
            //毕业后几年的数组
            foreach ($gra_year as $key => $value) {
                $ring[$value['gra_year']]['0']['value'] = $table[$value['gra_year']]['no'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND related = 0 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['1']['value'] = $table[$value['gra_year']]['bit'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND related = 1 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['2']['value'] = $table[$value['gra_year']]['lot'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND related = 2 AND `parent_id` in (".$ids.")")->count();
                $ring[$value['gra_year']]['3']['value'] = $table[$value['gra_year']]['whole'] = DB('info')->where("gra_year = '".$value['gra_year']."' AND related = 3 AND `parent_id` in (".$ids.")")->count();
            }
            foreach ($ring as $key => &$value){
                foreach ($value as $key1 => &$value1) {
                     $value1['name'] = $related[$key1];
                }
            }
            //组装成图表格式
            foreach ($table as $key2 => $value2) {
                $value2 = array_values($value2);
                $option[$key2]['xAxis']['type'] = 'category';
                $option[$key2]['xAxis']['data'] = $option2[$key2]['legend']['data'] = $related;
                $option[$key2]['yAxis']['type'] = 'value';
                $option[$key2]['series']['data'] = $value2;
                $option[$key2]['series']['type'] = 'bar';
                $option2[$key2]['tooltip']['trigger'] = 'item';
                $option2[$key2]['tooltip']['formatter'] = "{b}:{c}人({d}%)";
                $option2[$key2]['legend']['orient'] = 'vertical';
                $option2[$key2]['legend']['x'] = 'left';
                $option2[$key2]['series']['name'] = '访问来源';
                $option2[$key2]['series']['type'] = 'pie';
                $option2[$key2]['series']['radius'] = array('50%','70%');
                $option2[$key2]['series']['avoidLabelOverlap'] = false;
                $option2[$key2]['series']['label']['normal']['show'] = false;
                $option2[$key2]['series']['label']['normal']['position'] = 'center';
                $option2[$key2]['series']['label']['emphasis']['show'] = true;
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontSize'] = '30';
                $option2[$key2]['series']['label']['emphasis']['textStyle']['fontWeight'] = 'bold';
                $option2[$key2]['series']['labelLine']['normal']['show'] = false;
                $option2[$key2]['series']['data'] = $ring[$key2];
            }
            foreach($relateds as $k => $v)
                    $relateds1[] = $related[$v['name']];
            //近几年公司融资情况
            foreach($relateds as $key_type => &$value_type){
                $value_type['type'] = 'line';
                foreach($year as $key_type1 => $value_type1){
                    $value_type['data'][] = DB('info')->where("year = '".$value_type1['year']."' AND related = '".$value_type['name']."' AND `parent_id` in (".$ids.")")->count();
                }
                $value_type['name'] = $related[$value_type['name']];
            }
            $option3['0']['title']['text'] = '毕业跟踪趋势走向图';
            $option3['0']['tooltip']['trigger'] = 'axis';
            $option3['0']['legend']['data'] = $relateds1;
            $option3['0']['grid']['left'] = '3%';
            $option3['0']['grid']['right'] = '3%';
            $option3['0']['grid']['bottom'] = '3%';
            $option3['0']['grid']['containLabel'] = true;
            $option3['0']['toolbox']['feature']['saveAsImage'] = '';
            $option3['0']['xAxis']['type'] = 'category';
            $option3['0']['xAxis']['boundaryGap'] = false;
            $option3['0']['xAxis']['data'] = $years;
            $option3['0']['yAxis']['type'] = 'value';
            $option3['0']['series'] = $relateds;
        }
        foreach($option as &$value)
            $value = My::encodeJson($value);
        foreach ($option2 as &$value)
            $value = My::encodeJson($value);
        if(!empty($option3)){
            foreach ($option3 as &$value)
                $value = My::encodeJson($value);
            $result['option3'] = $option3;
        }
        if(!empty($option4)){
            foreach ($option4 as &$value)
                $value = My::encodeJson($value);
            $result['option4'] = $option4;
        }
        if(!empty($option5)){
            foreach ($option5 as &$value)
                $value = My::encodeJson($value);
            $result['option5'] = $option5;
        }
        $result['table'] = $table;
        $result['option'] = $option;
        $result['option2'] = $option2;
        return $result;
    }

}